package com.hdy.redislikerankinglist.controller;

import com.hdy.redislikerankinglist.pojo.RestResponse;
import com.hdy.redislikerankinglist.service.RedisService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@RestController
@Tag(name = "点赞接口")
@RequestMapping("/redis")
@RequiredArgsConstructor
public class Redis {
    private final RedisService redisService;
    @GetMapping(value = "/giveLike/{id}/{username}")
    @Operation(summary= "用户点赞接口", description = "用户点赞接口")
    public RestResponse giveLike(@PathVariable String id,@PathVariable String username) {
      return redisService.giveLike(id,username);
    }

   /* @GetMapping(value = "/giveCancelLike/{id}/{username}")
    @Operation(summary= "用户取消点赞接口", description = "用户取消点赞接口")
    public RestResponse giveCancelLike(@PathVariable String id,@PathVariable String username) {
        redisUtil.srem("like:"+id,username);
        return ResultGenerator.genSuccessResult(success,"取消成功!");
    }*/

    @GetMapping(value = "/isGiveLike/{id}/{username}")
    @Operation(summary = "判断用户是否点赞", description = "判断用户是否点赞")
    public RestResponse isGiveLike(@PathVariable String id,@PathVariable String username) {
       return redisService.isGiveLike(id,username);
    }

    @GetMapping(value = "/getGiveLikeList/{id}")
    @Operation(summary = "获取点赞列表", description = "获取点赞列表")
    public RestResponse getGiveLikeList(@PathVariable String id) {
        return redisService.getGiveLikeList(id);
    }

    @GetMapping(value = "/getGiveLikeSize/{id}")
    @Operation(summary = "获取点赞人数")
    public RestResponse getGiveLikeSize(@PathVariable String id) {
       return redisService.getGiveLikeSize(id);
    }
}
